<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of PaisDao
 *
 * @author UP23
 */
class PaisDao extends BaseDao{


    public function obterTodos(){
        $sql = "select id, nome from pais order by nome;";
        $stmt = $this->getPreparedStatment($sql);
        $stmt->execute();

        /* bind variables to prepared statement */
        $stmt->bind_result($id, $nome);

        $i = 0;
        $paises=array();
        /* fetch values */
        while ($stmt->fetch()) {
            $pais = new Pais();
            $pais->setId($id);
            $pais->setNome($nome);
            
            $paises[$i++] = $pais;
        }

        $stmt->close();

        return $paises;
        
    }

    public function inserir($pais){
         $sql = "insert into pais (nome) values(?);";
         $stmt = $this->getPreparedStatment($sql);
         $stmt->bind_param('s', $pais->getNome());
         $stmt->execute();
         $stmt->close();         
    }

    public function obterEstados($pais){

    }

    public function __destruct(){
         echo "<b><br/><br/>Rodei o destruct de Pais!<br/><br/></b>";
         $this->fecharConexao();
    }
}
?>
